package object

import (
	"fmt"
	"time"

	. "gddgame.cc/galaxy/common/dsl/game/ai"
	. "gddgame.cc/galaxy/common/dsl/game/attr"
)

const SettingObjectName = "setting_object"

type ObjectCategory byte

const (
	TargetObjectCategory ObjectCategory = iota
	PropObjectCategory
	BuildObjectCategory
	PowerObjectCategory
	TowerObjectCategory
	RobotObjectCategory
)

type SettingObject struct {
	Id        int               `json:"id" orm:"auto" sql:"INT"`
	Name      map[string]string `json:"name" sql:"JSON"`
	BaseId    int               `json:"baseId" sql:"INT"`
	Category  ObjectCategory    `json:"category" sql:"INT"`
	Identity  int               `json:"identity" sql:"INT"`
	Entity    string            `json:"entity" sql:"VARCHAR"`
	LiveTime  int               `json:"liveTime" sql:"INT"`
	Attr      AttrEffectSlice   `json:"attr" sql:"JSON"`
	Ai        []ModelAi         `json:"ai" sql:"JSON"`
	AttrEvent [][]AttrEvent     `json:"attrEvent" sql:"JSON"`

	// 扩展参数：游戏端
	Extend interface{} `json:"extend" sql:"JSON"`
	// 扩展参数：服务端
	Inside interface{} `json:"inside" sql:"JSON"`

	Group     []int `json:"group" sql:"JSON"`
	Difficult int   `json:"difficult" sql:"INT"`

	UpdateTime *time.Time `json:"update_time" orm:"updateTime" sql:"DATETIME"`
}

func (object *SettingObject) MakeKey() string {
	return fmt.Sprintf("O_%d", object.Id)
}
